﻿using LuaInterface;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LUALearn2 : MonoBehaviour
{
    public string luaResourcePath;
    LuaState mLuaState;
    LuaFunction mLuaFunction;


    void Awake()
    {
        mLuaState = new LuaState();
        mLuaState.Start();
        LuaBinder.Bind(mLuaState);//把各种unity的接口绑定进LUA.
        DelegateFactory.Init();//初始化各种委托

        var textAsset = Resources.Load<TextAsset>(luaResourcePath);
        mLuaState.DoString(textAsset.text, "LUALearn2.cs");
        mLuaFunction = mLuaState.GetFunction("Update");
    }

    void Update()
    {
        mLuaFunction.Call(transform);
    }

    void OnDestroy()
    {
        mLuaState.Dispose();
    }
}
